package com.lsismo.core.base.util;

import java.util.ArrayList;


public class PageBean {
	
	private  int start = 0;
	private  int limit = 99999;
	private  int totalCount = 0;
	private String queryHql;
	private Object result;
	private Object[] values;
	
	private String groupBy ; 
	
	public void setGroupBy(String column) {
		
		if(column!=null)
		this.groupBy = " group by "+column+" ";
	}
	
	public Object[] getValues() {
		return values;
	}
	public void setValues(Object[] values) {
		this.values = values;
	}
	
	
	public String getQueryHql() {
		
		String hql =queryHql;
		if(groupBy!=null)
			hql += groupBy;
		
		return hql;
	}
	
	public void setQueryHql(String queryHql) {
		this.queryHql = queryHql;
	}
	
	
	public int getStart() {
		return start;
	}
	public void setStart(int start) {
		this.start = start;
	}
	
	public void setStart(String start) {
		
		int ascall = -1;
		if(start!=null&&!"".equals(start.trim())){
			for (int i = 0; i < start.length(); i++) {
				ascall = start.charAt(i);
				if(ascall<'0'|| ascall>'9') return;
			}
			this.start = Integer.parseInt( start );
		}
	}
	
	
	public int getLimit() {
		return limit;
	}
	public void setLimit(int limit) {
		this.limit = limit;
	}
	
	public void setLimit(String limit) {
		
		int ascall = -1;
		if(limit!=null&&!"".equals(limit.trim())){
			for (int i = 0; i < limit.length(); i++) {
				ascall = limit.charAt(i);
				if(ascall<'0'|| ascall>'9') return;
			}
			this.limit = Integer.parseInt( limit );
		}
	}
	
	public int getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
	
	@SuppressWarnings("unchecked")
	public Object getResult() {
		if(result==null)
			result = new ArrayList();
		return result ;
	}
	public void setResult(Object result) {
		this.result = result;
	}
	
	
}
